
layui.use(['form','jquery','table','layer'],function() {
    var form = layui.form
        , $ = layui.jquery
        , table = layui.table
        , layer = layui.layer;

    reset = function reset(){
        $('select[name=classId]').val('0');
        $('input[name = courseName]').val("");
        $('select[name=coursePrice]').val('0');
        $('select[name=userId]').val('0');
        $('select[name=courseCstatus]').val('0');
        $('input[name = courseLabel]').val("");
    }

    search = function search() {
        var classId = $('select[name=classId]').val();
        var courseName = $('input[name = courseName]').val();
        var coursePrice = $('select[name=coursePrice]').val();
        var trueName = $('select[name=trueName]').val();
        var courseCstatus = $('select[name=courseCstatus]').val();
        var courseLabel = $('select[name = courseLabel]').val();

        if(classId == ''){
            classId = '';
        }else if(classId == 'java'){
            classId = 2;
        }else if(classId == 'spring'){
            classId = 3;
        }
        if(coursePrice == ''){
            coursePrice = '';
        }else if(coursePrice == '全部'){
            coursePrice = '';
        }else if(coursePrice == '大于100'){
            coursePrice = 100;
        }else if(coursePrice == '小于100'){
            coursePrice = -100;
        }
        if(courseCstatus == ''){
            courseCstatus = '';
        }else if(courseCstatus == '全部'){
            courseCstatus = '';
        }else if(courseCstatus == '未审核'){
            courseCstatus = 3;
        }else if(courseCstatus == '审核中'){
            courseCstatus = 4;
        }else if(courseCstatus == '审核失败'){
            courseCstatus = 5;
        }else{
            courseCstatus = 6;
        }
        if(courseLabel == ''){
            courseLabel = '';
        }else if(courseLabel == '全部'){
            courseLabel = '';
        }

        var object = {
            'classId': classId
            ,'courseName': courseName
            ,'coursePrice': coursePrice
            ,'trueName': trueName
            ,'courseCstatus': courseCstatus
            ,'courseLabel': courseLabel
        }

        $.ajax({
            url: '/course/advancedRetrieval'
            ,data: object
            ,dataType: 'json'
            ,success:function(data){
                $('#zzq').val("zzq");
                parent.tableRender(data.data);
                var layer = parent.layer;
                layer.close(layer.index);
            }
        });

    }


});